from pynput.keyboard import Key, Listener
import pydirectinput as pdi
import pyautogui as pyg
import keyboard
import time
import threading

fangxiang="right"
def duo_chong_bao_tou():
    global fangxiang
    inner = threading.Thread(target=dcbt_inner)
    inner.start()
    inner.join

def dcbt_inner():
    global fangxiang
    for i in range(1,23):
        print(f"方向键被按下： {fangxiang}")
        pdi.keyDown(fangxiang)
        time.sleep(0.2)
        pdi.keyUp(fangxiang)
def change_fangxiang(fx):
    global fangxiang
    fangxiang = fx
def left_key():
    change_fangxiang("left")
def right_key():
    change_fangxiang("right")
def up_key():
    change_fangxiang("up")
def down_key():
    change_fangxiang("down")
keyboard.add_hotkey("q", duo_chong_bao_tou)
keyboard.add_hotkey("q+left", left_key)
keyboard.add_hotkey("q+right", right_key)
keyboard.add_hotkey("q+up", up_key)
keyboard.add_hotkey("q+down", down_key)
keyboard.wait("ctrl+q")